﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hack.Misc.BodyCalculations
{
    /// <summary>
    /// Body mass index Calculations
    /// </summary>
    public class Bmi
    {
        public double Height { get; internal set; }
        public double Weight { get; internal set; }
        public double BMI { get; internal set; }
        public double BodyFatPrecentage { get; internal set; }
        public Sex Sex { get; internal set; }
        public int Age { get; internal set; }
        public Bmi(Sex sex, int age, double height, HeightType lType, double weight, WeightType wtype)
        {
            this.Sex = sex;
            this.Age = age;
            this.Height = lType == HeightType.Cm ? height : Math.Length.InchToCm(height);
            this.Weight = wtype == WeightType.Kg ? weight : Math.Weight.LbsToKg(weight);


            double _length = this.Height / 100;

            this.BMI = this.Weight / (_length * _length);
            this.BodyFatPrecentage =
                (1.2 * this.BMI) +
                (0.24 * age) -
                (sex == BodyCalculations.Sex.Man ? /*Man*/16.2 : /*Woman*/5.4);
        }
        public override string ToString()
        {
            return String.Format(
@"Underweight   Ideal Weight   Overweight   Obesity
   < 19          19-25         26-30       > 30

BMI: {0} with a Height of {1}cm, Weight of {2}kg, Fat%: {3} and Sex: {4}",
                this.BMI,
                this.Height,
                this.Weight,
                this.BodyFatPrecentage,
                this.Sex);
        }
        public enum WeightType : int
        {
            Lbs = 1,
            Kg = 0
        }
        public enum HeightType : int
        {
            Inch = 1,
            Cm = 0
        }
    }
}